package com.yuan.department.controller;

import com.alibaba.fastjson.JSON;
import com.yuan.department.entity.Dept;
import com.yuan.department.service.IDeptService;
import com.yuan.department.service.impl.DeptServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @program: Train
 * @description:
 * @author: yuan_boss
 * @create: 2022-11-25 11:48
 **/
@WebServlet("/DeptServlet/*")
public class DeptServlet extends BaseServlet {
    private IDeptService service = new DeptServiceImpl();

    public void listDept(HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException {
        List<Dept> list = service.list();
        String json = JSON.toJSONString(list);
        response.getWriter().println(json);
    }
}
